\documentclass{report}
\usepackage{graphicx}
\usepackage{algorithm2e}
\usepackage{amsmath}

\begin{document}
\tableofcontents
\chapter{Background}
I guess that I should put a bit of background information on image processing. Well the scientific question is to find a decent system for applying certain convolution operators on an image in a reasonable amount of time. I should probably also go through the basic structure of how the system works. Since it does have to work in 2D with a 1D data stream.
\chapter{Algorithms}
The algorithms used for this implementation are as follows.
\section{Convolution Operations}
This takes us through the basics of how a Convolution Operator works and what it can be used for.

\begin{algorithm}[H]
\SetAlgoLined
\KwData{K = Convolution Kernel, I = Input Data}
\KwResult{O = Output Data}
M = number of rows in Input \\
N = number of columns in Input \\
\For{i in N}{
\For{j in M}{
O(i,j) = CKF(i, j, K, I)
}
}
\caption{This is the overarching function}
\end{algorithm}

\begin{algorithm}[H]
\SetAlgoLined
\KwData{K = Convolution Kernel, I = Input Data}
\KwResult{O = Output Data}
\For{k in n}{
\For{l in m}{
value = value + I(i + k - 1, j + l - 1)K(k,l)}
}
O(i,j) = value \\
value = 0
\caption{This defines the Convolution Kernel Function(CKF)}
\end{algorithm}
\subsection{Convolution Kernel}
\[ \left[ \begin{array} {ccc}
(0,0) & (0,1) & (0,2) \\
(1,0) & (1,1) & (1,2) \\
(2,0) & (2,1) & (2,2) \\
\end{array} \right] \]
\section{Gaussian Blur/Smoothing}
This goes through how to develop a convolution kernel to apply Gaussian Smoothing. \\
$G(x,y) = \dfrac{1}{2 \pi \sigma^2} e^{-\dfrac{x^2+y^2}{2\sigma^2}}$ \\
From this Gaussian function there are a few different approaches to obtaining the kernel. The simplest is that you define the size of your kernel say 3x3. Then for each of the points in the kernel you get the value from the Gaussian function. The alternative approach is to recognise that each value in the kernel represents a certain area of the Gaussian function and do the integral to get the actually value.
\[ \left[ \begin{array} {ccc}
(0,0) & (0,1) & (0,2) \\
(1,0) & (1,1) & (1,2) \\
(2,0) & (2,1) & (2,2) \\
\end{array} \right] \]
So taking this matrix and an $\sigma=1.5$ we get a new matrix which looks like the following.
\[ \left[ \begin{array} {ccc}
0.0453542 & 0.0566406 & 0.453542 \\
0.0566406 & 0.0707355 & 0.0566406 \\
0.0453542 & 0.0566406 & 0.0453542  \\
\end{array} \right] \]
The final thing which has to be done is to normalise the kernel so that when all of the values are added together it has a value of 1. The total sum of the previous matrix is 0.4787147 so each of the 9 values needs to by divided by that value. The resulting matrix looks as follows.
\[ \left[ \begin{array} {ccc}
0.0947416 & 0.118318 & 0.0947416 \\
0.118318  & 0.147761 & 0.118318  \\
0.0947416 & 0.118318 & 0.0947416 \\
\end{array} \right] \]
\section{Sobel}
The goes through the kernel that is used to apply the edge detection along with how the system works in a more abstract sense. \\
This is the convolution kernel for the X axis.
\[ \left[ \begin{array} {ccc}
-1 & 0 & 1 \\
-2 & 0 & 2 \\
-1 & 0 & 1 \\
\end{array} \right] \]
This is the convolution kernel for the Y axis.
\[ \left[ \begin{array} {ccc}
-1 & -2 & -1 \\
0 & 0 & 0 \\
1 & 2 & 1 \\
\end{array} \right] \]
\begin{algorithm}[H]
\SetAlgoLined
\KwData{I = Input Data}
\KwResult{O = Output Data}

M = number of rows in Input \\
N = number of columns in Input \\
\For{i in N}{
\For{j in M}{
$pixelX$ = CKF(i, j, SobelX, I) \\
$pixelY$ = CKF(i, j, SobelY, I) \\
O(i,j) = $\sqrt{pixelX^2 + pixelY^2}$
}
}
\caption{This shows how the Sobel algorithm works in an abstract sense.}
\end{algorithm}

\chapter{Verification}
I have no idea what kind of verification I am going to use probably gimp can help and some unit testing to ensure that certain sections of the algorithmic structure are working.
\chapter{Performance}
Will probably go through images of different sizes and colour against grayscale see how they compare.

\end{document}